import QtQuick 2.6
import QtQuick.Layouts 1.2

import "../../Base/UiBase"
import "../../Base/Config"

import Cpp.Type 1.0

import "../../FallView" as FallView
import "../Post" as Post
Item {
    ColumnLayout {
        anchors.fill: parent
        Filter {
            id: filter
            Layout.fillWidth: true
            Layout.preferredHeight: 50 * Size.ratio
        }
        ListModel {
            id: listmodel
            Component.onCompleted: {
                listmodel.append({
                                     username: "欢乐的0403",
                                     head: "../../../resources/tests/touxiang02.svg",
                                     subject: Subject.Music,
                                     time: new Date().toISOString(),
                                     location: "广西 来宾",
                                     imageCount: 1,
                                     image: "../../../resources/tests/121025539394.jpg",
                                     comment: "123123"
                                 })
                listmodel.append({
                                     username: "欢乐的0403",
                                     head: "../../../resources/tests/touxiang02.svg",
                                     subject: Subject.Music,
                                     time: new Date().toISOString(),
                                     location: "广西 来宾",
                                     imageCount: 1,
                                     image: "../../../resources/tests/355X630.jpg",
                                     comment: "123123"
                                 })
                listmodel.append({
                                     username: "欢乐的0403",
                                     head: "../../../resources/tests/touxiang02.svg",
                                     subject: Subject.Music,
                                     time: new Date().toISOString(),
                                     location: "广西 来宾",
                                     imageCount: 8,
                                     image: "../../../resources/tests/355X400.jpg",
                                     comment: "123123"
                                 })
            }
        }

        Item {
            Layout.fillWidth: true
            Layout.fillHeight: true
            z: -1
            FallView.FallView {
                id: postHolderParent

                onFlickStarted: foot.opacity = 0.3
                onFlickEnded: {
                    var left = contentHeight - (contentY + height + 1)
                    if (left < 10 * Size.ratio) {
                        PostLoader.loadMore()
                    }
                    foot.opacity = 1
                }
                onMovementStarted: foot.opacity = 0.3
                onMovementEnded: foot.opacity = 1

                anchors.fill: parent

                delegate: Post.AdvPost {
                    width: parent.width
                    username: model.username
                    headSource: model.head
                    subject: model.subject
                    time: model.time
                    location: model.location
                    imageCount: model.imageCount
                    imageSource: model.image
                    commentText: model.comment
                }

                model:listmodel
            }
        }
    }
    FootButton {
        parent: indexRoot
        id: foot
        anchors.fill: parent
    }
}
